package com.mapapp.flutter_mapapp.widget;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.view.View;

import com.mapapp.flutter_mapapp.R;

import razerdp.basepopup.BasePopupWindow;

public class CacheWarnDialog extends BasePopupWindow {

    private CardView cvEnsure;
    private CardView cvCancel;
    private CardView cvContinue;


    public CacheWarnDialog(Context context) {
        super(context);

        init();
    }

    @Override
    public View onCreateContentView() {
        View view = createPopupById(R.layout.dialog_cache_warn);
        cvEnsure = view.findViewById(R.id.cv_ensure);
        cvCancel = view.findViewById(R.id.cv_cancel);
        cvContinue = view.findViewById(R.id.cv_continue);
        return view;
    }

    @Override
    public boolean onBackPressed() {
        return true;
    }

    private void init() {

        cvEnsure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        cvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onClickUploading();
                }
                dismiss();
            }
        });

        cvContinue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onClickContinue();
                }
                dismiss();
            }
        });

    }

    public interface OnItemClickListener {
        void onClickUploading();

        void onClickContinue();
    }

    private OnItemClickListener listener;

    public void setListener(OnItemClickListener listener) {
        this.listener = listener;
    }
}
